/**
 * Created by Administrator on 2016/10/13.
 */
url = 'http://ekang.ren/'
publicJs = {
    //    提示
    propmt :　function(desc){
        $('body').append('<div class="rem" style="width: 100%;height: 100%;position: fixed;top:0;z-index: 99999999;"><div style="background: rgba(0,0,0,.7) ; color: #fff; min-width: 100px; border-radius: 5px; font-size: 16px; text-align: center; z-index:999999;width: auto; height: auto; padding: 10px 7px;position: absolute;" class="propmt animate_sc">'+desc+'</div></div>');
        var w_w = $(window).width();
        var h_h = $(window).height();
        var p_w = $('.propmt').width();
        var p_h = $('.propmt').height();
        var top = (h_h-p_h)/2;
        var left = (w_w-p_w)/2;
        $('.propmt').css('top',top);
        $('.propmt').css('left',left);
        setTimeout(function(){
            $('.rem').remove();
        },2000);
    },
    //    获取连接参数
    getQueryString : function(name){
        var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
        var r = window.location.search.substr(1).match(reg);
        if (r != null) return unescape(decodeURI(r[2])); return null;
    },
    //    弹层
    layer : function (content){
        $('body').append('<div class="elasticlayer animatescale" style=" z-index: 9999999999999; position: fixed; top:0; width: 100%; height:100%; background:rgba(0,0,0,.6) "><div class="elasticlayercon" style=" background: rgba(255,255,255,.9); border-radius: 5px; width: 70%;position: absolute;"><div class="tit" style=" width: 100%; color:#35424b; text-align: center; padding: 5% 0; font-size: 5vw">易康医疗温馨提醒</div><p style=" width: 90%; margin: auto; text-align: center; font-size: 4.5vw; padding: 5% 0 10% 0; ">'+content+'</p><button style=" display: block; background: none; border: none; padding: 5% 0; font-size:5.5vw; color: #00b57d; width: 100%; border-top: 1px solid #ddd; letter-spacing: 1px;">ok</button></div></div>');
        var w_w = $(window).width();
        var h_h = $(window).height();
        var p_w = $('.elasticlayer .elasticlayercon').width();
        var p_h = $('.elasticlayer .elasticlayercon').height();
        var top = (h_h-p_h)/2;
        var left = (w_w-p_w)/2;
        $('.elasticlayer .elasticlayercon').css('top',top);
        $('.elasticlayer .elasticlayercon').css('left',left);
        $(document).on('click','.elasticlayer .elasticlayercon button',function(){
            $('.elasticlayer .elasticlayercon').addClass('animatescale2');
            $('.elasticlayer').addClass('animatescale3')
            setTimeout(function(){
                $('.elasticlayer').remove();
                $('.publicmask').remove();
            },500);
        });
    },
    //    get
    get : function (texturl,data,success){
        $.ajax({
            type : 'get',
            url : url+texturl,
            dataType : 'jsonp',
            data : data,
            success : function(response) {
                success(response);
            }
        });
    },
    //    空白页面
    pagenull : function(desc){
        $('body').append('<div class="emptypage" style="position: fixed;top:0;width:256px;height:300px;overflow: hidden;z-index: 5001;background: none;left: 50%; top: 50%; -webkit-transform: translate(-50%, -50%); position: absolute"><div class="con" style="width: 256px;height: auto;overflow: hidden;margin: auto;left: 50%; top: 50%; -webkit-transform: translate(-50%, -50%); position: absolute"><img style="width: 114px;height: auto;overflow: hidden;margin: auto;" src="../img/icon27.png"><p style="font-size: 14px;text-align: center;color: #35424b;margin: 20px 0;">'+desc+'</p></div></div>')
        //$('.emptypage .con button').live('click',function(){
        //    location.href=url
        //});
        $('.emptypage').on('touchmove', function (event) {
            event.preventDefault();
        });
    },
//    动态修改微信标题
    modify_wx_tit : function(name){
        var $body = $('body');
        document.title = name;
        var $iframe = $('<iframe src=""></iframe>');
        $iframe.on('load',function() {
            setTimeout(function() {
                $iframe.off('load').remove();
            }, 0);
        }).appendTo($body);
    }
}